package com.swfee.qinben.dto.base;

import com.swfee.qinben.session.AppSession;
import com.swfee.qinben.session.UserSession;

public abstract class BaseReqDto {

	public static final String ENCODING = "UTF-8";

	public abstract String propsToUrlString();

	@Override
	public String toString() {
		return propsToUrlString();
	}

	public String propsToUrl() {
		StringBuffer sb = new StringBuffer();
		if (AppSession.getTerminalCode() != null) {
			sb.append("terminalCode=" + AppSession.getTerminalCode());

		}
		if(UserSession.isLogined()){
			if (UserSession.getAppCode() != null) {
				sb.append("&appCode=" + UserSession.getAppCode());
	
			}
			if (UserSession.getUserId() != null) {
				sb.append("&userId=" + UserSession.getUserId());
				sb.append("&roleCode=" + UserSession.getRoleCode());
			}
			int roleType = UserSession.getRoleType();
			if(roleType != 2){
				switch (roleType) {
				case 1:
					sb.append("&doctorId=" + UserSession.getUserId());
					break;

				case 3:
					sb.append("&nurseId=" + UserSession.getUserId());
					break;
				
				}
			}
			
		}
		else{
			sb.append("&appCode=" + "111ddd");
		}
		String str = propsToUrlString();
		if (str != null && str.length() != 0) {
			sb.append("&" + str);
		}

		return sb.toString();
	}

}
